package com.helei.service.Impl;

import cn.hutool.http.HttpRequest;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import lombok.Data;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

/**
 * @ Tool：IntelliJ IDEA
 * @ Author：hl
 * @ Date：2024-05-17-下午4:38
 */
@Setter
@Data
@Configuration
@Slf4j
public class QQProperties {
	private final String httpUrl = "http://127.0.0.1:5700";
	private String qq = null;
	@PostConstruct
	private void get_login_info() {
		String result = HttpRequest.post(httpUrl + "/get_login_info")
				.timeout(20000)//超时，毫秒
				.execute().body();
		JsonObject data = new JsonParser().parse(result).getAsJsonObject().get("data").getAsJsonObject();
		log.info("登陆QQ号:{},昵称:{}", data.get("user_id").getAsString(), data.get("nickname").getAsString());
		setQq(data.get("user_id").getAsString());
	}
}
